<template>
  <div class="gjf-tabbar">
    <div :class="active==1?'gjf-tabbar-item-sel':'gjf-tabbar-item'" v-on:click="gjftt(1)">
      <span class="iconfont icon-shouye-mendianshu"></span>
      <p>首页</p>
    </div>
    <div :class="active==2?'gjf-tabbar-item-sel':'gjf-tabbar-item'" v-on:click="gjftt(2)">
      <span class="iconfont icon-sousuo"></span>
      <p>搜索</p>
    </div>
    <div :class="active==3?'gjf-tabbar-item-sel':'gjf-tabbar-item'" v-on:click="gjftt(3)">
      <span class="iconfont icon-gouwuche2"></span>
      <p>购物车</p>
    </div>
    <div :class="active==4?'gjf-tabbar-item-sel':'gjf-tabbar-item'" v-on:click="gjftt(4)">
      <span class="iconfont icon-geren"></span>
      <p>个人</p>
    </div>
  </div>
</template>

<script>
export default {
  name: "",
  data() {
    return {
        active:1
    };
  },
  computed: {},
  watch: {},
  methods: {
    gjftt(i){
      this.active=i
      if(i==1){
        this.$router.push('/')
      }else if(i==2){
        this.$router.push('/search')
      }else if(i==3){
        this.$router.push('/cart')
      }else if(i==4){
        this.$router.push('/my')
      }
    }
  },
  mounted(){
    let gjfaa=window.location.href
    if(gjfaa.endsWith('/')){
      this.active=1
    }else if(gjfaa.endsWith('/search')){
      this.active=2
    }else if(gjfaa.endsWith('/cart')){
      this.active=3
    }else if(gjfaa.endsWith('/my')){
      this.active=4
    }
  }

};
</script>

<style scoped>
.gjf-tabbar{
  width: 100%;
  height: 4rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: fixed;
  background: white;
  left: 0;
  bottom: 0;
  box-shadow: 5px 1px 5px gray;
}
.gjf-tabbar-item{
  flex: 1;
  text-align: center;
}
.gjf-tabbar-item span{
  font-size: 1.375rem;
}
.gjf-tabbar-item-sel{
  flex: 1;
  text-align: center;
  color: red;
}
.gjf-tabbar-item-sel span{
  font-size: 1.375rem;
}
</style>
